package com.smscenter.server.core.vcomcn;

import com.smscenter.server.core.IExecutor;
import com.zeus.base.smscenter.common.constant.SmsConstants;
import com.zeus.base.smscenter.common.constant.VComcnConstants;
import com.zeus.base.smscenter.common.util.WebUtils;

import java.io.IOException;
import java.util.Map;

/**
 * Created by Administrator on 2016-02-17.
 */
public class VComVoiceExecutor implements IExecutor {

    public String excute(Map<String, Object> params) throws IOException {
        String loginName = (String) params.get("loginName");//用户名
        String loginPassword = (String) params.get("loginPassword");//密码
        String phone = (String) params.get("phone");//电话号
        String content = (String) params.get("content");//内容
        String bizNo = (String) params.get("bizNo");//唯一ID
        StringBuffer sb = new StringBuffer();
        sb.append("<Group Login_Name=\"").append(loginName).append("\" Login_Pwd=\"").append(loginPassword).append("\" OpKind=\"2\" InterFaceID=\"15\">");
        sb.append("<B_Time></B_Time>");
        sb.append("<E_Time></E_Time>");
        sb.append("<Fail_Retry_Times>1</Fail_Retry_Times>");//重复测试
        sb.append("<R_Interval>60</R_Interval>");
        sb.append("<Display_Number></Display_Number>"); //显示号码
        sb.append("<Voice_Action_Num>1</Voice_Action_Num>");//允许重听（1为允许、0为不允许）
        sb.append("<Link_Tel>");
        sb.append("</Link_Tel>");
        sb.append("<Item>");
        sb.append("<Task>");
        sb.append("<Tts_Content><![CDATA[").append(content).append("]]>");//信息内容
        sb.append("</Tts_Content>");
        sb.append("<Recive_Phone_Number1>").append(phone).append("</Recive_Phone_Number1>"); //呼叫号码
        sb.append("<Recive_Phone_Number2></Recive_Phone_Number2>");
        sb.append("<Recive_Phone_Number3></Recive_Phone_Number3>");
        sb.append("<Search_ID>").append(bizNo).append("</Search_ID>"); //唯一ID
        sb.append("</Task>");
        sb.append("</Item>");
        sb.append("</Group>");
        System.out.println(sb);
        String rsp = WebUtils.doPost(VComcnConstants.SMS_URL, sb.toString(), SmsConstants.CHARSET_GBK, 10000, 10000);
        return rsp;
    }
}
